﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace CannedHeater.View.Converters
{
    /// <summary>
    /// Negates a boolean (null -> true)
    /// (Usage suggestion: control enabled if IsEnabled binded value is false)
    /// </summary>
    public class BooleanNegationConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return true; // Assume negated "false"

            bool b = (bool) value;
            return !b;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null; // Not needed
        }
    }
}
